<template>
	<view class="container">
		<block v-if="isload">
			<view class="artilce-top" v-if="set.bgpic"  @tap="goto" :data-url="set.jumpurl">
				<image :src="set.bgpic" mode="widthFix"></image>
			</view>
			<view class="article_list">
				<!--横排-->
				<view  class="article-itemlist" v-for="(item,index) in datalist" :key="item.id"
					@click="goto" :data-url="'/pages/article/detail?id='+item.id">
					<view class="article-info">
						<view class="p1">{{item.name}}</view>
					</view>
					<view class="article-pic">
						<view class="videoplay" v-if="item.video">
							<image src="../../static/img/play.png"></image>
						</view>
						<image class="image" :src="item.pic" mode="widthFix" />
					</view>
				</view>
				
			</view>
		</block>
		<nodata v-if="nodata"></nodata>
		<nomore v-if="nomore"></nomore>
		<loading v-if="loading"></loading>
		<dp-tabbar :opt="opt"></dp-tabbar>
		<popmsg ref="popmsg"></popmsg>
	</view>
</template>

<script>
	var app = getApp();

	export default {
		data() {
			return {
				opt: {},
				loading: false,
				isload: false,
				menuindex: -1,

				nodata: false,
				nomore: false,
				keyword: '',
				datalist: [],
				pagenum: 1,
				clist: [],
				cnamelist: [],
				cidlist: [],
				datalist: [],
				cid: 0,
				bid: 0,
				listtype: 0,
				set: '',
				look_type: false,
			};
		},
		onLoad: function(opt) {
			this.opt = app.getopts(opt);
			this.cid = this.opt.cid || 0;
			this.bid = this.opt.bid || 0;
			this.look_type = this.opt.look_type || false;
			if (this.opt.keyword) {
				this.keyword = this.opt.keyword;
			}
			this.getdata();
		},
		onPullDownRefresh: function() {
			this.getdata();
		},
		onReachBottom: function() {
			if (!this.nomore && !this.nodata) {
				this.pagenum = this.pagenum + 1;
				this.getdata(true);
			}
		},
		methods: {
			getdata: function(loadmore) {
				if (!loadmore) {
					this.pagenum = 1;
					this.datalist = [];
				}
				var that = this;
				var pagenum = that.pagenum;
				var keyword = that.keyword;
				var cid = that.cid;
				console.log(cid)
				that.loading = true;
				that.nodata = false;
				that.nomore = false;
				app.post('Article/getartlist', {
					bid: that.bid,
					cid: cid,
					pagenum: pagenum,
					keyword: keyword
				}, function(res) {
					that.loading = false;
					var data = res.data;
					if (pagenum == 1) {
						that.clist = res.clist;
						that.set = res.set;
						
						uni.setNavigationBarTitle({
							title: res.title
						});
						that.datalist = data;
						if (data.length == 0) {
							that.nodata = true;
						}
						that.loaded();
					} else {
						if (data.length == 0) {
							that.nomore = true;
						} else {
							var datalist = that.datalist;
							var newdata = datalist.concat(data);
							that.datalist = newdata;
						}
					}
				});
			},
			searchConfirm: function(e) {
				var that = this;
				var keyword = e.detail.value;
				that.keyword = keyword
				that.getdata();
			},
			changetab: function(cid) {
				this.cid = cid;
				uni.pageScrollTo({
					scrollTop: 0,
					duration: 0
				});
				if (this.listtype == 2) {
					this.$refs.waterfall.refresh();
				}
				this.getdata();
			},
		}
	};
</script>
<style>
	page {
		background: #e8ebf2
	}
	.artilce-top{
		
	}
	.artilce-top image{
		width: 100%;
	}
	.article_list {
		padding: 10rpx 16rpx;
		background: #f6f6f7;
		margin-top: 6rpx;
	}


	.article_list .article-itemlist {
		display: inline-block;
		position: relative;
		/* margin-bottom: 12rpx; */
		padding: 30rpx 0rpx;
		background: #fff;
		display: flex;
		border-radius: 8rpx;
		margin: 20rpx;
	}

	.article_list .article-itemlist .article-pic {
		width: 200rpx;
		height: 200rpx;
		overflow: hidden;
		background: #ffffff;
		padding-bottom: 25%;
		position: relative;
		border-radius: 16rpx;
	}

	.article_list .article-itemlist .article-pic .image {
		position: absolute;
		top: 0;
		left: 0;
		width: 100%;
		height: auto
	}

	.article_list .article-itemlist .article-info {
		width: 65%;
		height: auto;
		overflow: hidden;
		padding: 0 20rpx;
		display: flex;
		flex-direction: column;
		justify-content: space-between
	}

	.article_list .article-itemlist .article-info .p1 {
		color: #222222;
		font-weight: bold;
		font-size: 28rpx;
		line-height: 46rpx;
		display: -webkit-box;
		-webkit-box-orient: vertical;
		-webkit-line-clamp: 2;
		overflow: hidden;
		height: 92rpx
	}

	.article_list .article-itemlist .article-info .p2 {
		display: flex;
		flex-grow: 0;
		flex-shrink: 0;
		font-size: 24rpx;
		color: #a88;
		overflow: hidden;
		padding-bottom: 6rpx
	}

	.article_list .article-item3 {
		width: 32%;
		display: inline-block;
		position: relative;
		margin-bottom: 12rpx;
		background: #fff;
		border-radius: 8rpx;
	}

	/*.article-item3:nth-child(even){margin-right:2%}*/
	.article_list .article-item3 .article-pic {
		width: 100%;
		height: 0;
		overflow: hidden;
		background: #ffffff;
		padding-bottom: 70%;
		position: relative;
		border-radius: 8rpx 8rpx 0 0;
	}

	.article_list .article-item3 .article-pic .image {
		position: absolute;
		top: 0;
		left: 0;
		width: 100%;
		height: auto
	}

	.article_list .article-item3 .article-info {
		padding: 10rpx 20rpx 20rpx 20rpx;
		display: flex;
		flex-direction: column;
	}

	.article_list .article-item3 .article-info .p1 {
		color: #222222;
		font-weight: bold;
		font-size: 28rpx;
		line-height: 46rpx;
		display: -webkit-box;
		-webkit-box-orient: vertical;
		-webkit-line-clamp: 2;
		overflow: hidden;
	}

	.article_list .article-item3 .article-info .p2 {
		flex-grow: 0;
		flex-shrink: 0;
		display: flex;
		align-items: center;
		padding-top: 10rpx;
		font-size: 24rpx;
		color: #a88;
		overflow: hidden
	}

	.p3 {
		color: #8c8c8c;
		font-size: 28rpx;
		line-height: 46rpx;
		display: -webkit-box;
		-webkit-box-orient: vertical;
		-webkit-line-clamp: 2;
		overflow: hidden;
	}
	.videoplay{
		position: absolute;
		z-index: 10;
		left: 60rpx;
		top: 60rpx;
	}
	.videoplay image{
		width: 40px;
		height: 40px;
		text-align: center;
	}
</style>